import 'package:encrypt/encrypt.dart';
import 'package:flutter/services.dart';
import 'package:startapp/rsa/rsaPubKey.dart';

String encodeAESString(String content) {
// 加密的秘钥

  final key = Key.fromUtf8('my 32 length key................');
// 初始化的向量官方代码里是这么注释的{Represents an Initialization Vector}
  final iv = IV.fromLength(16);
//加密容器
  final encrypter = Encrypter(AES(key));
//加密部分
  final encrypted = encrypter.encrypt(content, iv: iv);

  return encrypted.base64;
//解密部分
  // final decrypted = encrypter.decrypt(encrypted, iv: iv);
}

// Future<String> encodeRSAString(String content) async {
// // 加密的秘钥
//   final pubPem = await rootBundle.loadString("key");
//   var parse = RSAKeyParser().parse(pubPem);
//   final encrypter = Encrypter(RSA(publicKey: parse));
// //加密部分
//   final encrypted = encrypter.encrypt(content);

//   return encrypted.base64;
// //解密部分
//   // final decrypted = encrypter.decrypt(encrypted, iv: iv);
// }
